import { reqSettleAccounts } from "@/api";

export default {
    actions: {
        // 获取用户地址信息和用户商品清单
        async getSettleAccounts({ commit }) {
            let result = await reqSettleAccounts()
            if (result.code == 200) {
                commit("GETSETTLEACCOUNTS", result.data)
            }
        }
    },
    mutations: {
        GETSETTLEACCOUNTS(state, data) {
            state.settleAccountsInfo = data
        }
    },
    state: {
        settleAccountsInfo: {}
    },
    getters: {
        // 用户地址信息
        userAddressList(state) {
            return state.settleAccountsInfo.userAddressList || []
        },
        // 商品清单数据
        userDetailArrayList(state) {
            return state.settleAccountsInfo.detailArrayList || []
        },
        // 总商品数量
        totalNum(state) {
            return state.settleAccountsInfo.totalNum
        },
        // 总价格
        totalAmount(state) {
            return state.settleAccountsInfo.totalAmount
        },
        // 应付价格
        originalTotalAmount(state) {
            return state.settleAccountsInfo.originalTotalAmount
        },
        // 商品编码
        tradeNo(state) {
            return state.settleAccountsInfo.tradeNo
        }
    },
}